'''
Created on Dec 23, 2010

@author: Nican
'''

import wx

import octorotor.joystick.Controler as Controler

class JoystickValues(wx.BoxSizer):
    '''
    classdocs
    '''


    def __init__(self, parent):
        '''
        Constructor
        '''
        wx.BoxSizer.__init__(self, wx.VERTICAL)
        
        self.PGauge = wx.Gauge(parent, -1, 100, size=wx.Size(-1,10))
        self.YGauge = wx.Gauge(parent, -1, 100, size=wx.Size(-1,10))
        self.RGauge = wx.Gauge(parent, -1, 100, size=wx.Size(-1,10))
        self.ZGauge = wx.Gauge(parent, -1, 100, size=wx.Size(-1,10))
        
        self.Add(wx.StaticText(parent, -1, "Pitch"), 0, wx.EXPAND)
        self.Add(self.PGauge, 0, wx.EXPAND)
        self.Add(wx.StaticText(parent, -1, "Yaw"), 0, wx.EXPAND)
        self.Add(self.YGauge, 0, wx.EXPAND)
        self.Add(wx.StaticText(parent, -1, "Roll"), 0, wx.EXPAND)
        self.Add(self.RGauge, 0, wx.EXPAND)
        self.Add(wx.StaticText(parent, -1, "Throttle"), 0, wx.EXPAND)
        self.Add(self.ZGauge, 0, wx.EXPAND)
        
    def updateData(self, joystickData):
        
        if joystickData is None:
            joystickData = Controler.Singleton.getData()
        
        self.PGauge.SetValue( (joystickData.angle.p + 1.0) * 50 )
        self.YGauge.SetValue( (joystickData.angle.y + 1.0) * 50 )
        self.RGauge.SetValue( (joystickData.angle.r + 1.0) * 50 )
        self.ZGauge.SetValue( (joystickData.zVal + 1.0) * 50 )
        